package nuc.edu.tlias.mapper;

import nuc.edu.tlias.pojo.Student;
import org.apache.ibatis.annotations.*;

import javax.naming.Name;
import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {


    public void delete(@Param("ids")Integer[] ids);

    public List<Student> findall(@Param("name") String name, @Param("degree") Integer degree, @Param("clazzId") Integer clazzId);

    void save(Student student);

    @Select("SELECT id, name, no, gender, phone, id_card, is_college, address, degree, graduation_date, clazz_id, violation_count, violation_score, create_time, update_time from student where id = #{id}")
    Student getById(Integer id);

    void upload(Student student);

    @Update("update student set violation_count = violation_count+1 ,violation_score = violation_score + #{score} where id = #{id}")
    void violation(@Param("id") Integer id, @Param("score") Integer score);

    @MapKey("name")
    List<Map<String, Object>> getStudentDegreeData();

    @MapKey("name")
    List<Map<String, Object>> getStudentCount();
}
